close all;
clear all;

%ppm samples are just from the top to the middle
%topmost scan is at the top
%5 lateral locations, 500 um spacing (see paper)


kk= 1;  %corresponds to pre-anneal
cd pre-anneal;
filenames = {...
    '10_04_01_934 [Counter] vs [Piezo X], [Piezo Y], [Piezo Obj Z].mat', ... 
    '11_17_04_638 [Counter] vs [Piezo X], [Piezo Y], [Piezo Obj Z].mat', ... 
    '12_30_03_515 [Counter] vs [Piezo X], [Piezo Y], [Piezo Obj Z].mat', ...
    '13_43_08_945 [Counter] vs [Piezo X], [Piezo Y], [Piezo Obj Z].mat', ...  
    '14_56_18_554 [Counter] vs [Piezo X], [Piezo Y], [Piezo Obj Z].mat', ...
    };

for ii = 1:5 %ii marks which spot it is
    load(filenames{ii});
    dataext{kk,ii} = data.data{1};
    for jj = 1:length(dataext{kk,ii}(1,1,:));
         avecounts{kk,ii}(jj) = mean(mean(dataext{kk,ii}(:,:,jj)));
       % avecounts{kk,ii}(jj)
        imagesc(dataext{kk,ii}(:,:, jj));
        colorbar; 
        %pause;
    end
end

kk = 2;  %corresponds to 980 anneal
cd ..
cd 980C_150hr_ppm
cd 'depth scan 1'
filenames = {...
    '16_39_27_762 [Counter] vs [Piezo X], [Piezo Y], [Piezo Obj Z].mat', ...  
    '17_44_33_371 [Counter] vs [Piezo X], [Piezo Y], [Piezo Obj Z].mat', ...  
    '18_49_44_050 [Counter] vs [Piezo X], [Piezo Y], [Piezo Obj Z].mat', ...  
    '19_54_54_997 [Counter] vs [Piezo X], [Piezo Y], [Piezo Obj Z].mat', ...  
    '21_00_07_393 [Counter] vs [Piezo X], [Piezo Y], [Piezo Obj Z].mat', ...  
    };
for ii = 1:5 %ii marks which spot it is
    load(filenames{ii});
    dataext{kk,ii} = data.data{1};
    for jj = 1:length(dataext{kk,ii}(1,1,:));
        avecounts{kk,ii}(jj) = mean(mean(dataext{kk,ii}(:,:,jj)));
      %  avecounts{kk,ii}(jj)
        imagesc(dataext{kk,ii}(:,:, jj));
        colorbar;
        %pause; 
    end
end

kk = 3;  %corresponds to 1000 anneal
cd ..
cd ..
cd 1000C_150hr
cd 'depth scan'
filenames = {...
    '13_00_07_793 [Counter] vs [Piezo X], [Piezo Y], [Piezo Obj Z].mat', ...  
    '14_10_09_494 [Counter] vs [Piezo X], [Piezo Y], [Piezo Obj Z].mat', ...  
    '15_19_26_836 [Counter] vs [Piezo X], [Piezo Y], [Piezo Obj Z].mat', ...  
    '16_29_36_041 [Counter] vs [Piezo X], [Piezo Y], [Piezo Obj Z].mat', ...  
    '17_38_56_114 [Counter] vs [Piezo X], [Piezo Y], [Piezo Obj Z].mat', ...   
    };
for ii = 1:5 %ii marks which spot it is
    load(filenames{ii});
    dataext{kk,ii} = data.data{1};
    for jj = 1:length(dataext{kk,ii}(1,1,:));
         avecounts{kk,ii}(jj) = mean(mean(dataext{kk,ii}(:,:,jj)));
       % avecounts{kk,ii}(jj)
        imagesc(dataext{kk,ii}(:,:, jj));
        colorbar;
        %pause; 
    end
end

kk = 4;  %corresponds to 150 anneal 1
cd ..
cd ..
cd 1050C_150hr
cd 'Depth scan'
cd 'top_good'
filenames = {...
    '09_49_16_473 [Counter] vs [Piezo X], [Piezo Y], [Piezo Obj Z].mat', ...  
    '10_58_36_034 [Counter] vs [Piezo X], [Piezo Y], [Piezo Obj Z].mat', ...  
    '12_08_36_545 [Counter] vs [Piezo X], [Piezo Y], [Piezo Obj Z].mat', ... 
    '13_18_04_954 [Counter] vs [Piezo X], [Piezo Y], [Piezo Obj Z].mat', ...  
    '14_27_09_811 [Counter] vs [Piezo X], [Piezo Y], [Piezo Obj Z].mat', ...   
    };
for ii = 1:5 %ii marks which spot it is
    load(filenames{ii});
    dataext{kk,ii} = data.data{1};
    for jj = 1:length(dataext{kk,ii}(1,1,:));
         avecounts{kk,ii}(jj) = mean(mean(dataext{kk,ii}(:,:,jj)));
        %avecounts{kk,ii}(jj)
        imagesc(dataext{kk,ii}(:,:, jj));
        colorbar;
        %pause; 
    end
end

kk = 5;  %corresponds to 150 anneal 2
cd ..
cd ..
cd ..
cd 1050C_150hr_2
cd 'depth scan'
filenames = {...
    '15_14_50_267 [Counter] vs [Piezo X], [Piezo Y], [Piezo Obj Z].mat', ...  
    '16_19_34_162 [Counter] vs [Piezo X], [Piezo Y], [Piezo Obj Z].mat', ...  
    '17_24_12_408 [Counter] vs [Piezo X], [Piezo Y], [Piezo Obj Z].mat', ...  
    '18_28_52_906 [Counter] vs [Piezo X], [Piezo Y], [Piezo Obj Z].mat', ...  
    '19_33_36_680 [Counter] vs [Piezo X], [Piezo Y], [Piezo Obj Z].mat', ...  
    };
for ii = 1:5 %ii marks which spot it is
    load(filenames{ii});
    dataext{kk,ii} = data.data{1};
    for jj = 1:length(dataext{kk,ii}(1,1,:));
         avecounts{kk,ii}(jj) = mean(mean(dataext{kk,ii}(:,:,jj)));
        avecounts{kk,ii}(jj)
        imagesc(dataext{kk,ii}(:,:, jj));
        colorbar;
        %pause; 
    end
end

cd ..
cd ..

save avecountsppm


